<template>
	<view class="container">
		<uni-nav-bar class="ch-nav" height="88rpx" backgroundColor="#ffffff" leftWidth="90rpx" rightWidth="90rpx" color="#333" :fixed="true" :padding="false" :border="true" @clickLeft="$goBack(1)">
			<template slot="left">
				<image class="left" src="@/public/images/public/dhl_fhjt.png" mode="aspectFit"></image>
			</template>
			<text class="title">{{ expertName ? expertName + '的' : '' }}联赛方案</text>
			<template slot="right"></template>
		</uni-nav-bar>
		<view class="body flex-c">
			<ArticleList v-if="seasonArticle[0]" :list="seasonArticle" :showHead="false" :showResult="true"></ArticleList>
			<EmptyContent v-else top="220rpx" text="暂无更新的方案" img="qsy_zwxl" :showRefresh="requestError" @refresh="getSeasonArticles"></EmptyContent>
			<view class="list-end flex-r mb20" v-if="isEnd">
				<text>已经到底啦～</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				expertId: null,
				expertName: null,
				seasonArticle: [],
				requestError: false,
				pageNo: 1,
				isEnd: false
			};
		},
		onLoad() {
			console.log(this.$Route.query);
			this.query = this.$Route.query
			this.expertId = this.query.eid
			this.getSeasonArticles()
		},
		onReachBottom() {
			if(!this.isEnd){
				this.getSeasonArticles()
			}
		},
		methods: {
			//联赛方案
			getSeasonArticles() {
				let data = {}
				if(this.query.seasonId && this.query.sportId){
					data.seasonId = this.query.seasonId
					data.sportId = this.query.sportId
				}
				this.$http.post({
					url: '/api/user/article/list',
					data: {
						enablePay: 1,
						expertId: this.expertId,
						pageNo: this.pageNo,
						pageSize: 15,
						...data
					}
				}).then(data => {
					console.log(data);
					if(data.success){
						if(data.result && data.result.total){
							if(data.result.current == 1){
								this.expertName = data.result.records[0].expertName
								this.seasonArticle = data.result.records
							}else{
								this.seasonArticle.push(...data.result.records)
							}
							this.isEnd = data.result.current >= data.result.pages
							this.pageNo = data.result.current + 1
						}
					}else{
						this.requestError = true
					}
				}).catch((err) => {
					console.log(err);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		.body{
			padding: 0 20rpx var(--safe-area-inset-bottom);
			min-height: calc(var(--safe-height) - #{$navbar-height});
		}
	}
</style>
